<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <link th:href="@{favicon.ico}" rel="shortcut icon"/>
    <link rel="stylesheet" th:href="@{/layui/css/layui.css}"/>
    <link rel="stylesheet" th:href="@{/css/common/main.css}"/>
    <link rel="stylesheet" th:href="@{/css/plugins/font-awesome-4.7.0/css/font-awesome.min.css}" media="all">
    <title>cms-开源社区管理</title>
</head>
<body class="timo-layout-page">
<div class="layui-card">
    <div class="layui-card-header timo-card-header">
        <span><i class="fa fa-bars"></i> 维修记录管理</span>
        <i class="layui-icon layui-icon-refresh refresh-btn"></i>
    </div>
    <div class="layui-card-body">
        <div class="layui-row timo-card-screen put-row">
            <div class="pull-left layui-form-pane timo-search-box">
                <div class="layui-inline">
                    <label class="layui-form-label">楼号</label>
                    <div class="layui-input-block">
                        <input type="text" name="buildingNo" th:value="${repairInfo?.buildingNo}" placeholder="请输入楼号"
                               autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">房号</label>
                    <div class="layui-input-block">
                        <input type="text" name="roomNo" th:value="${repairInfo?.roomNo}" placeholder="请输入房号"
                               autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">维修状态</label>
                    <div class="layui-input-block">
                        <select class="layui-input" type="text" name="status" placeholder="维修状态" style="width: 100px">
                            <option th:selected="${repairInfo?.status=='全部'}">全部</option>
                            <option th:selected="${repairInfo?.status=='申请中'}">申请中</option>
                            <option th:selected="${repairInfo?.status=='维修中'}">维修中</option>
                            <option th:selected="${repairInfo?.status=='已维修'}">已维修</option>
                        </select>
                    </div>
<!--                    <div class="layui-input-block">-->
<!--                        <input type="text" name="status" th:value="${repairInfo?.status}" placeholder="请输入维修状态"-->
<!--                               autocomplete="off" class="layui-input">-->
<!--                    </div>-->
                </div>
                <div class="layui-inline">
                    <button class="layui-btn timo-search-btn">
                        <i class="fa fa-search"></i>
                    </button>
                </div>
            </div>
            <div class="pull-right screen-btn-group">
                <div class="btn-group-right">
                    <button class="layui-btn open-popup" data-title="添加用户" th:attr="data-url=@{/admin/repair/addRepair}" data-size="auto">
                        <i class="fa fa-plus-square-o" aria-hidden="true"></i> 添加
                    </button>
                    <button class="layui-btn">
                        <i class="fa fa-trash-o" aria-hidden="true"></i><a class="ajax-status" th:href="@{/admin/repair/deleteMultiple}" style="color: rgb(255,255,255)"> 删除</a>
                    </button>
                </div>
            </div>
        </div>
        <div class="timo-table-wrap">
            <table class="layui-table timo-table">
                <thead>
                <tr>
                    <th class="timo-table-checkbox">
                        <label class="timo-checkbox"><input type="checkbox">
                            <i class="layui-icon layui-icon-ok"></i></label>
                    </th>
                    <th data-field="buildingNo">楼号</th>
                    <th data-field="roomNo">房号</th>
                    <th data-field="details">维修内容</th>
                    <th data-field="status">维修状态</th>
                    <th data-field="applicationDate">申请日期</th>
                    <th data-field="repairDate">维修日期</th>
                    <th data-field="whetherFromBalance">是否从基金余额支出</th>
                    <th data-field="repairMen">维修人</th>
                    <th data-field="money">维修费用</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                <tr th:each="item:${repairInfoList}">
                    <td>
                        <label class="timo-checkbox">
                            <input type="checkbox" th:value="${item.id}">
                            <i class="layui-icon layui-icon-ok"></i></label>
                    </td>
                    <td th:text="${item.buildingNo}">楼号</td>
                    <td th:text="${item.roomNo}">房号</td>
                    <td th:text="${item.details}">维修内容</td>
                    <td th:text="${item.status}">维修状态</td>
                    <td th:text="${item.applicationDate}">申请日期</td>
                    <td th:text="${item.repairDate}">维修日期</td>
                    <td th:text="${item.whetherFromBalance}">是否从基金余额支出</td>
                    <td th:text="${item.repairMen}">维修人</td>
                    <td th:text="${item.money}">维修费用</td>
                    <td>
                        <a class="open-popup" data-title="编辑用户" th:attr="data-url=@{'/admin/repair/editRepair/'+${item.id}}"
                           data-size="600,600" href="#">编辑</a>
                        <a class="open-popup" data-title="详细信息" th:attr="data-url=@{'/admin/repair/detailRepair/'+${item.id}}"
                           data-size="800,400" href="#">详细</a>
                        <a class="ajax-get" th:attr="data-msg='您是否删除'"
                           th:href="@{'/admin/repair/deleteRepair/'+${item.id}}">删除</a>
                    </td>
                </tr>
                </tbody>
            </table>
        </div>
        <div class="layui-row">
            <div class="layui-col-sm6">
                <div class="page-info">
                    <span>显示 [[${pageInfo.startRow}]]/[[${pageInfo.endRow}]] 条，共 [[${pageInfo.total}]] 条记录</span>
                </div>
            </div>
            <div class="layui-col-sm6">
                <ul class="pagination list-page">
                    <li class="page-item"><a class="page-link">上一页</a></li>
                    <li th:class="${num == pageInfo.pageNum} ? 'page-item active' : 'page-item'"
                        th:each="num:${pageInfo.navigatepageNums}">
                        <a class="page-link breviary" th:text="${num}" th:attr="page=${num}"></a>
                    </li>
                    <li class="page-item"><a class="page-link">下一页</a>
                    </li>
                </ul>
            </div>
        </div>
    </div>
</div>
    <script th:src="@{/layui/layui.js}"></script>
    <script th:src="@{/js/plugins/layer/layer.min.js}"></script>
    <script th:src="@{/js/common/main.js}"></script>
    <script th:src="@{/js/plugins/jquery.min.js}"></script>
    <script>
        $(".page-link").on("click", function (e){
            let getSearch = "";
            // 搜索框参数
            $('.timo-search-box [name]').each(function (key, val) {
                if ($(val).val() !== "" && $(val).val() !== undefined) {
                    getSearch += $(val).attr("name") + "=" + $(val).val() + "&";
                }
            });
            if($(this).text()==='上一页'){
                if ([[${pageInfo.pageNum}]]===1){
                    // console.log("点击了上一页无效")
                }else {
                    getSearch += "pageNum=" + (Number($(".active").children().text())-1) + "&";
                    if (getSearch !== "") {
                        getSearch = "?" + getSearch.substr(0, getSearch.length - 1);
                    }
                    //console.log(window.location.pathname + getSearch);
                    window.location.href = window.location.pathname + getSearch;
                }
            }
            else if($(this).text()==='下一页'){
                if ([[${pageInfo.pageNum}]]===[[${pageInfo.pages}]]){
                    //console.log("点击了下一页无效")
                }else {
                    getSearch += "pageNum=" +(Number($(".active").children().text())+1) + "&";
                    if (getSearch !== "") {
                        getSearch = "?" + getSearch.substr(0, getSearch.length - 1);
                    }
                    //console.log(window.location.pathname + getSearch);
                    window.location.href = window.location.pathname + getSearch;
                }
            }else {
                getSearch += "pageNum=" + $(this).text() + "&";
                if (getSearch !== "") {
                    getSearch = "?" + getSearch.substr(0, getSearch.length - 1);
                }
                //console.log(window.location.pathname + getSearch)
                window.location.href = window.location.pathname + getSearch;
            }
        })
    </script>
</body>
</html>